class MyQueue:

    def __init__(self):
        """
        Initialize your data structure here.
        0 : 为头
        1 ：为尾
        """
        self.stack = []
        self.status = 0


    def push(self, x: int) -> None:
        """
        Push element x to the back of queue.
        """
        if self.status == 0:
            tmp = []
            while self.stack:
                tmp.append(self.stack.pop())
            self.stack = tmp
            self.status = 1
        self.stack.append(x)


    def pop(self) -> int:
        """
        Removes the element from in front of queue and returns that element.
        """
        if self.status == 1:
            tmp = []
            while self.stack:
                tmp.append(self.stack.pop())
            self.stack = tmp
            self.status = 0
        return self.stack.pop()

    def peek(self) -> int:
        """
        Get the front element.
        """
        if self.status == 0:
            return self.stack[-1]
        else:
            return self.stack[0]


    def empty(self) -> bool:
        """
        Returns whether the queue is empty.
        """
        return len(self.stack) == 0

if __name__ == '__main__':
    queue =  MyQueue()
    queue.push(1);
    queue.push(2);
    queue.push(3);
    r = queue.peek(); # 返回
    # 1
    print(r)
    r = queue.pop(); # 返回
    # 1
    print(r)
    r = queue.pop();  # 返回
    # 1
    print(r)
    r = queue.pop();  # 返回
    # 1
    print(r)
    r = queue.empty(); # 返回
    # false
    print(r)